home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / htdocs / xampp / phonebook.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  4.2 KB  |  110 lines

  1. <?php include("langsettings.php"); ?>
  2. <html>
  3.     <head>
  4.         <meta name="author" content="Kai Oswald Seidler">
  5.         <link href="xampp.css" rel="stylesheet" type="text/css">
  6.         <title></title>
  7.     </head>
  8.  
  9.     <body>
  10.          <p>
  11.  
  12.         <h1><?=$TEXT['phonebook-head']?></h1>
  13.  
  14.         <?=$TEXT['phonebook-text1']?><p>
  15.         <?=$TEXT['phonebook-text2']?><p>
  16.  
  17.         <?php
  18.             // Copyright (C) 2003 Kai Seidler <oswald@apachefriends.org>
  19.             //
  20.             // This program is free software; you can redistribute it and/or modify
  21.             // it under the terms of the GNU General Public License as published by
  22.             // the Free Software Foundation; either version 2 of the License, or
  23.             // (at your option) any later version.
  24.             //
  25.             // This program is distributed in the hope that it will be useful,
  26.             // but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.             // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  28.             // GNU General Public License for more details.
  29.             //
  30.             // You should have received a copy of the GNU General Public License
  31.             // along with this program; if not, write to the Free Software
  32.             // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  33.  
  34.             if (!($db = sqlite_open('sqlite/phonebook', '0666'))) {
  35.                 echo "<h2>".$TEXT['phonebook-error']."</h2>";
  36.                 die;
  37.             }
  38.         ?>
  39.  
  40.         <h2><?php echo $TEXT['phonebook-head1']; ?></h2>
  41.  
  42.         <table border="0" cellpadding="0" cellspacing="0">
  43.             <tr bgcolor="#f87820">
  44.                 <td><img src="img/blank.gif" alt="" width="10" height="25"></td>
  45.                 <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib1']; ?></b></td>
  46.                 <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib2']; ?></b></td>
  47.                 <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib3']; ?></b></td>
  48.                 <td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo $TEXT['phonebook-attrib4']; ?></b></td>
  49.                 <td><img src="img/blank.gif" alt="" width="10" height="25"></td>
  50.             </tr>
  51.  
  52.             <?php
  53.                 $firstname=$_REQUEST['firstname'];
  54.                 $lastname=$_REQUEST['lastname'];
  55.                 $phone=$_REQUEST['phone'];
  56.  
  57.                 if($firstname!="")
  58.                 {
  59.                         sqlite_query($db,"INSERT INTO users (firstname,lastname,phone) VALUES('$firstname','$lastname','$phone')");
  60.                 }
  61.  
  62.                 if($_REQUEST['action']=="del")
  63.                 {
  64.                         sqlite_query($db,"DELETE FROM users WHERE id={$_REQUEST['id']};");
  65.                 }
  66.  
  67.                 $result=sqlite_query($db,"SELECT id,firstname,lastname,phone FROM users ORDER BY lastname;");
  68.  
  69.                 $i = 0;
  70.                 while ($row = sqlite_fetch_array($result)) {
  71.                     if ($i > 0) {
  72.                         echo "<tr valign='bottom'>";
  73.                         echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
  74.                         echo "</tr>";
  75.                     }
  76.                     echo "<tr valign='middle'>";
  77.                     echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
  78.                     echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
  79.                     echo "<td class='tabval'>".$row['firstname']." </td>";
  80.                     echo "<td class='tabval'>".$row['phone']." </td>";
  81.  
  82.                     echo "<td class='tabval'><a onclick=\"return confirm('".$TEXT['phonebook-sure']."');\" href='phonebook.php?action=del&id=".$row['id']."'><span class='red'>[".$TEXT['phonebook-button1']."]</span></a></td>";
  83.                     echo "<td class='tabval'></td>";
  84.                     echo "</tr>";
  85.                     $i++;
  86.                 }
  87.  
  88.                 echo "<tr valign='bottom'>";
  89.                 echo "<td bgcolor='#fb7922' colspan='6'><img src='img/blank.gif' alt='' width='1' height='8'></td>";
  90.                 echo "</tr>";
  91.  
  92.                 sqlite_close($db);
  93.             ?>
  94.  
  95.         </table>
  96.  
  97. <h2><?=$TEXT['phonebook-head2']?></h2>
  98.  
  99. <form action=phonebook.php method=get>
  100. <table border=0 cellpadding=0 cellspacing=0>
  101. <tr><td><?=$TEXT['phonebook-attrib1']?>:</td><td><input type=text size=20 name=lastname></td></tr>
  102. <tr><td><?=$TEXT['phonebook-attrib2']?>:</td><td> <input type=text size=20 name=firstname></td></tr>
  103. <tr><td><?=$TEXT['phonebook-attrib3']?>:</td><td> <input type=text size=20 name=phone></td></tr>
  104. <tr><td></td><td><input type=submit border=0 value="<?=$TEXT['phonebook-button2']?>"></td></tr>
  105. </table>
  106. </form>
  107.         <?php include("showcode.php"); ?>
  108.     </body>
  109. </html>
  110.